<template>
	<view>
		<u-tabbar :border='false' :value="current?current:0" :fixed="true" :placeholder="true" activeColor="#0BAC5F"
			inactiveColor='#6B6B6B' :safeAreaInsetBottom="true" @change="handleTabClick">
			<u-tabbar-item v-for='(item,index) in tabList' :key="index" :badge='item.badge' :text="item.text">
				<image slot="inactive-icon" class="u-page__item__slot-icon" :src="item.iconPath+'.png'" mode="heightFix">
				</image>
				<image slot="active-icon" class="u-page__item__slot-icon" :src="item.selectedIconPath+'.png'" mode="heightFix">
				</image>
			</u-tabbar-item>
		</u-tabbar>
	</view>
</template>

<script>
	export default {
		name: "tabbar",
		props: {
			current: Number
		},
		data() {
			return {
				tabList: uni.getStorageSync('dgtabbar')
			};
		},
		methods: {
			handleTabClick(index) {
				// 使用 uni.switchTab 方法切换页面
				console.log(this.tabList[index].pagePath)
				if(this.tabList[index].pagePath=='/pages/tabbar/order'){
					uni.navigateTo({
						url: this.tabList[index].pagePath,
					})
				}else{
					uni.switchTab({
						url: this.tabList[index].pagePath,
					});
				}
				

			},
		},
		watch:{
			
		}
	}
</script>

<style lang="scss">
	.u-page__item__slot-icon {
		height: 39rpx;
	}

	::v-deep.u-tabbar__content__item-wrapper {
		height: 150rpx!important;
	}
</style>